/*河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
*/
package cn.javaxc.oa.action.system;
import java.io.*;
import java.util.*;
import java.sql.*;
import cn.javaxc.model.base.SQL;
import cn.javaxc.model.base.SQLList;
import cn.javaxc.model.base.SQLMap;
import cn.javaxc.model.base.SQLParam;
import cn.javaxc.model.page.BatisPage;
import cn.javaxc.mvcwork.controller.web.TreeBean;
import cn.javaxc.mvcwork.util.common.CommonUtil;
import cn.javaxc.mvcwork.util.common.MapListUtil;
import cn.javaxc.mvcwork.util.helper.FrameHelper;
import cn.javaxc.mvcwork.util.helper.TreeTableHelper;
import org.springframework.beans.factory.annotation.Autowired;
import cn.javaxc.system.action.base.BaseAction;
import cn.javaxc.oa.mapper.system.OvertimeSetMapper;
public class OvertimeSet extends BaseAction
{
    @Autowired(required=false)
	private OvertimeSetMapper mapper;
    /**
    加班时间设置
    */
    
    public Map overtimeSet() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> l_worktime=mapper.l_worktime(params,pagination);
        l_worktime.setPagedListInfo(pagination);
        result.put("l_worktime", l_worktime);
        
        return result;
    }
    /**
    增加时间
    */
    
    public Map overtimeAdd() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> s_hour=mapper.s_hour(params);
        result.put("s_hour", s_hour);
        
        
        SQLList<SQLMap> s_minute=mapper.s_minute(params);
        result.put("s_minute", s_minute);
        
        return result;
    }
    /**
    查看加班详情
    */
    
    public Map overtimedetil() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> t_worktime=mapper.t_worktime(params);
        SQLMap t_worktime_emt=t_worktime.getExistfirst();
        result.put("t_worktime", t_worktime_emt);
        
        
        SQLList<SQLMap> s_staff=mapper.s_staff(params);
        result.put("s_staff", s_staff);
        
        return result;
    }
    /**
    选择员工
    */
    
    public Map staffChoice() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        TreeBean tb;
        
        SQLList<SQLMap> s_user=mapper.s_user(params,pagination);
        s_user.setPagedListInfo(pagination);
        result.put("s_user", s_user);
        
        
        tb = createTreeBean("l_firm_treecols");
        SQLList<SQLMap> l_firm=mapper.l_firm(params);
        l_firm = l_firm.buildTree(tb,tb.getPid());
        result.put("l_firm", l_firm);
        
        
        params.def("CMID1",-1);
        SQLList<SQLMap> l_role=mapper.l_role(params);
        result.put("l_role", l_role);
        
        
        SQLList<SQLMap> s_type=mapper.s_type(params);
        SQLMap s_type_emt=s_type.getExistfirst();
        result.put("s_type", s_type_emt);
        
        return result;
    }
    /**
    */
    
    public Map d_worktime() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        mapper.d_worktime(params);
        
        return result;
    }
    /**
    增加时间修改
    */
    
    public Map overtimeAddSubmit() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        result.put("v_start_hour", SQL.setTime(null,getParameter("startHour"),getParameter("startMinute"),null)
        );
        
        
        result.put("v_end_hour", SQL.setTime(null,getParameter("endHour"),getParameter("endMinute"),null));
        
        
        params.def("work_day",null);
        params.def("v_start_hour","0");
        params.def("v_end_hour","0");
        int timeid = mapper.timeid(params);
        result.put("timeid", timeid);
        
        
        for (SQLMap emt:SQL.foreach(context.getParameter("person_id"),"person_id","\n")){
            params=new SQLParam(request,emt.getMap());
            mapper.overtimeAddSubmit(params);
        }
        
        return result;
    }
}